package com.tentact.servlets;

import com.tentact.service.MeetingsService;
import com.tentact.vo.Employee;
import com.tentact.vo.Meeting;
import com.tentact.vo.MeetingRoom;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "selectMeetingsServlet", value = "/selectMeetingsServlet")
public class selectMeetingsServlet extends HttpServlet {
    private MeetingsService service = new MeetingsService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String MeetingName = request.getParameter("MeetingName");
        String RoomName = request.getParameter("RoomName");
        String EmployeeName = request.getParameter("EmployeeName");
        String BeginTime = request.getParameter("dateComm");
        String EndTime = request.getParameter("dateEnd");
        String meetingComm = request.getParameter("meetingComm");
        String meetingEnd = request.getParameter("metingEnd");
        System.out.println(MeetingName);
        System.out.println(RoomName);
        System.out.println(EmployeeName);
        System.out.println(BeginTime);
        System.out.println(EndTime);
        System.out.println(meetingComm);
        System.out.println(meetingEnd);
        MeetingRoom meetingRoom = new MeetingRoom(RoomName);
        Employee employee = new Employee(1,EmployeeName);
        Meeting meeting = new Meeting(MeetingName,BeginTime,EndTime,meetingRoom,employee);
        List<Meeting> list = service.selectByroomting(meeting,meetingComm,meetingEnd);
        request.setAttribute("list",list);
        request.getRequestDispatcher("searchmeetings.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        doGet(request,response);
    }
}
